Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Amplitude tracking 로직 컴포넌트로 분리 #473

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

eonseok-jeon
Copy link
Member

Related Issue : Closes #460


🧑‍🎤 Summary

event tracking 로직이 기존에는 handler 함수 안에 포함되어 있어서 이를 분리해줬어요

이때 track이 필요한 곳이 <Button> 뿐 아니라 일반 <button><Link>, <a> 등 여러 군데에서 사용되고 있어서 Button에 props로 넘겨주는 것 대신 Track 컴포넌트를 새로 만드는 방법을 택했습니다.

일단 Button 컴포넌트에는 필수적으로 필요해서 각각에 감싸주기 보다 공통 Button component에 한 번 싸주었습니다

// Button.tsx

const Button = ({ eventName, ...props ) {
  const Tag = isLink ? Link : 'button';

  return (
    <AmplitudeEventTrack eventName={eventName}>
      <Tag>
        {/* ... */}
      </Tag>
    </AmplitudeEventTrack>
  );
};
<Button eventName="click-gnb-logout">
  {/* ... */}
</Button>

그 외는 아래와 같이 해주었어요

<AmplitudeEventTrack eventName="click-gnb-logout">
  <a>...</a>
</AmplitudeEventTrack>

tracking 하는데 있어서 살짝의 로직이 필요한 곳들은 그냥 track을 이용해줬습니다

@eonseok-jeon eonseok-jeon self-assigned this Dec 30, 2024
@eonseok-jeon eonseok-jeon linked an issue Dec 30, 2024 that may be closed by this pull request
Copy link

height bot commented Dec 30, 2024

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Refactor] Amplitude tracking 로직 컴포넌트로 분리
1 participant